home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / Supplement / Unsupported / Utilities / HexUnloader < prev    next >
Text File  |  1986-09-22  |  1KB  |  51 lines

  1. \ HexUnloader
  2. \ 11/21/85  jaf
  3. \  9/22/86  cdn Generalized to handle a sequence of words to be unloaded
  4. \ reads code words and creates a source file which when interpreted,
  5. \ recreates the words from hex codes
  6. \ Example:    " test" createHex
  7. \            unload' pstart
  8. \            unload' p;s
  9. \            doneHex
  10.  
  11. : writeCR 13 HERE C! HERE 1 write: topFile drop ;
  12.  
  13. : Unload { baddr blen -- }
  14.     HEX
  15.     blen baddr + baddr -2 AND DO
  16.         4 0 DO
  17.             j i 4* + @ 0
  18.             <# #s #> write: topFile abort" can't write file"
  19.             HERE 3 BLANKS ASCII , HERE 1+ C!
  20.             HERE 3 write: topFile drop
  21.         LOOP
  22.         writeCR
  23.     16 +LOOP
  24.     DECIMAL
  25.     0 HERE !
  26. ;
  27.  
  28. \ ( faddr flen -- )
  29. : createHex
  30.     new: loadFile
  31.     name: topFile
  32.     create: topFile abort" can't open file"
  33.     'type TEXT 'type MACA set: topFile
  34. ;
  35. : doneHex
  36.     remove: loadFile ;
  37.  
  38. \ ( faddr flen : word -- )
  39. : Unload' { \ theNFA -- }
  40.     @pfa dup nfa -> theNFA
  41.     latest    \ find the pfa of the word following our word
  42.     BEGIN dup pfa lfa @ theNFA >
  43.     WHILE pfa lfa @
  44.     REPEAT
  45.     " Create " write: topFile abort" can't write file"
  46.     theNfa n>count write: topFile drop
  47.     writeCR
  48.     over - Unload
  49.     writeCR
  50. ;
  51.